#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
@Project : bigDataProject 
@File    : pos_order_pay_interface.py
@IDE     : PyCharm 
@Author  : Mario
@Date    : 2022/11/15 09:48 
@Describe: POS订单支付接口
"""
from fastapi import APIRouter
from fast_api.model.dto.pos.order.pay.pos_order_pay_dto import PosOrderPayDTO
from fast_api.model.dto.baseResponseDto import BaseResponseDto
from fast_api.server.pos.order.pay.order_pay_server import OrderPayServer
from utils.log.api_log_decorator import api_log_decorator

pos_order_pay_route = APIRouter()


@api_log_decorator(switch=True)
@pos_order_pay_route.post("/", name="订单支付", response_model=BaseResponseDto)
async def pos_order_pay(payload: PosOrderPayDTO):
    order_pay_request = OrderPayServer(payload.brandCode, payload.env)
    if payload.orderNo is None:
        response_data = order_pay_request.all_order_pay()
    else:
        response_data = order_pay_request.order_pay(payload.orderNo)
    return response_data
